
layui.config({
    version:'1510164124181'
}).use(['form', 'laypage', 'layer', 'element'],function(){
    form = layui.form;
    layer = layui.layer;
    $ = layui.jquery;
    laypage = layui.laypage;//分页
    element = layui.element; //元素操作
    inituserdata();
});
function inituserdata() {
    let info="";
    let StartTime="";//$("#StartTime").val();
    let EndTime="";//$("#EndTime").val();
    $.ajax({
        url: httpurl + "/SelectLoginRecordList",
        cache: false,
        headers: {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Methods": "*",
            "Access-Control-Allow-Headers": "Authorization",
            "Authorization": GetTokenInfo()
        },
        contentType : 'application/json',
        data: {
            "page":pageNo,
            "pagesize":pageRecords,
            "StartTime":StartTime,
            "EndTime":EndTime
        },
        success: function (data) {
            // console.log(JSON.stringify(data));
            if (data.rtnCode == 200) {
                let dataInfo=data.data;
                if(dataInfo.length>0){
                    totalRecords =dataInfo[dataInfo.length-1].total;
                    for (let i=0;i<dataInfo.length;i++) {
                        info+='<tr>' +
                            '<td><input data-id="'+dataInfo[i].id+'" type="checkbox"  name="box" class="aceChild"/></td>' +
                            '<td>'+dataInfo[i].username+'</td>' +
                            '<td>'+dataInfo[i].ipurl+'</td>' +
                            '<td>'+dataInfo[i].pcinfo+'</td>' +
                            '<td>'+dataInfo[i].intime+'</td>' +
                            '<td>'+dataInfo[i].outtime+'</td>' +
                            '<td><a href="#" data-id="'+dataInfo[i].id+'" data-info="deleteLoginRecordList" onclick="DeleteInfo(this)">删除</a></td>' +
                            '</tr>';
                    }
                }else{
                    totalRecords =0;
                    info += '<tr>'
                        +'<td colspan="12" style="text-align:center;">未找到任何数据</td>'
                        +'</tr>';
                }
                $("#TableInfo tbody").html(info);
                layer.closeAll();
                page();
            }
        }
    })
};



function SearchInfo(){
    pageNo=1;
    inituserdata();
}
//分页
function page(){
    laypage.render({
        elem: 'page' //注意，这里的 test1 是 ID，不用加 # 号
        ,count:totalRecords //数据总数，从服务端得到
        ,curr: pageNo //获取起始页 location.hash.replace('#!fenye=', '')
        ,hash: 'fenye' //自定义hash值
        ,layout: ['count', 'prev', 'page', 'next', 'skip']
        ,jump: function(obj, first){
            //首次不执行
            if(!first){
                pageNo = obj.curr;
                pageRecords = obj.limit;// 当前页面记录数
                inituserdata();
            }
        }
    });
}
